<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of UserBind
 *
 * @author Administrator
 */

namespace frontend\behavior;

use yii\base\Behavior;
use Yii;
use frontend\library\validator\UserValidator;
use frontend\exception\UserException;

class UserBehavior extends Behavior {

    //put your code here
    public function validate() {
        
        $errorCode = UserValidator::isMobileValid($this->owner->mobile);

        if ($errorCode !== TRUE) {
            throw new UserException($errorCode);
        }

        $errorCode = UserValidator::isUsernameValid($this->owner->username);

        if ($errorCode !== TRUE) {
            throw new UserException($errorCode);
        }

        $errorCode = UserValidator::isPassWordVaild($this->owner->password);
        if ($errorCode !== TRUE) {
            throw new UserException($errorCode);
        }
        return true;

      
    }

}
